/*
 *  Copyright 2009 David Kuhn <david.s.kuhn at gmail.com>.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */
package com.google.code.teamtools.domain.impl;

import com.google.code.teamtools.domain.IRole;
import com.google.code.teamtools.domain.IRoleGroup;

/**
 * Role implementation.
 * 
 * @author David Kuhn
 */
public class Role implements IRole
{
	private Long id = null;
	private String abbreviation;
	private boolean acting = false;
	private IRoleGroup roleGroup;
    private String title;

    public Role()
    {
    }
    
    public Role(Long id)
    {
        setId(id);
    }

    public Role(String title)
    {
        setTitle(title);
    }
    
    public Role(String title, String abbreviation)
    {
    	this(title);
    	setAbbreviation(abbreviation);
    }

    public Role(String title, String abbreviation, IRoleGroup roleGroup)
    {
    	this(title, abbreviation);
    	setRoleGroup(roleGroup);
    }
    
    /* (non-Javadoc)
     * @see com.google.code.teamtools.domain.IRole#getAbbreviation()
     */
    public String getAbbreviation()
    {
    	return abbreviation;
    }
    
    /* (non-Javadoc)
     * @see com.google.code.teamtools.domain.IEntity#getId()
     */
    public Long getId()
    {
    	return id;
    }
    
    /* (non-Javadoc)
     * @see com.google.code.teamtools.domain.IRole#getRoleGroup()
     */
    public IRoleGroup getRoleGroup()
    {
    	return roleGroup;
    }

    /* (non-Javadoc)
     * @see com.google.code.teamtools.domain.IRole#getTitle()
     */
    public String getTitle()
    {
        return title;
    }

    /* (non-Javadoc)
     * @see com.google.code.teamtools.domain.IRole#setAbbreviation(java.lang.String)
     */
    public void setAbbreviation(String abbreviation)
    {
    	this.abbreviation = abbreviation;
    }
    
    /* (non-Javadoc)
     * @see com.google.code.teamtools.domain.IRole#setRoleGroup(com.google.code.teamtools.domain.IRoleGroup)
     */
    public void setRoleGroup(IRoleGroup roleGroup)
    {
    	this.roleGroup = roleGroup;
    }
    
    /* (non-Javadoc)
     * @see com.google.code.teamtools.domain.IRole#setTitle(java.lang.String)
     */
    public void setTitle(String title)
    {
        this.title = title;
    }
    
    public String toString()
    {
        StringBuilder sb = new StringBuilder();
        sb.append("AbstractResource[");
        sb.append("id:");
        sb.append(this.getId());
        sb.append("|title:");
        sb.append(this.getTitle());
        sb.append("|abbreviation:");
        sb.append(this.getAbbreviation());
        sb.append("|roleGroup:");
        sb.append(this.getRoleGroup().toString());
        sb.append("]");
        
        return sb.toString();
    }
    
    private void setId(Long id)
    {
    	this.id = id;
    }
}
